package com.pks.autoInsurance.helper;

import org.apache.log4j.Logger;

import com.pks.autoInsurance.dao.CustomerDAO;
import com.pks.autoInsurance.dao.CustomerDAOImpl;
import com.pks.autoInsurance.dao.VehicleDAO;
import com.pks.autoInsurance.dao.VehicleDAOImpl;
import com.pks.autoInsurance.dto.CustomerDto;
import com.pks.autoInsurance.dto.VehicleDto;

/**
 * Performs activities related to the Registration.
 * 
 * @author Pankaj Soni
 * 
 */
public class RegistrationHelper {

	private static final Logger LOGGER = Logger
			.getLogger(RegistrationHelper.class);

	/**
	 * Performs registration of the user.
	 * 
	 * @param customerDtoReq
	 * @return boolean
	 */
	public boolean registerUser(CustomerDto customerDtoReq) {
		LOGGER.debug("begin");
		CustomerDAO customerDAO = new CustomerDAOImpl();
		LOGGER.info("customerDtoReq:" + customerDtoReq);
		return customerDAO.createCustomer(customerDtoReq);
	}

	/**
	 * Checks for existing user.
	 * 
	 * @param customerDtoReq
	 * @return boolean
	 */
	public boolean isExistingUser(CustomerDto customerDtoReq) {
		LOGGER.debug("begin");
		CustomerDAO customerDAO = new CustomerDAOImpl();
		LOGGER.info("loginDtoReq:" + customerDtoReq);
		return customerDAO.isExistingUser(customerDtoReq);
	}

	/**
	 * Registers vehicle of user.
	 * 
	 * @param vehicleDto
	 * @return boolean
	 */
	public boolean registerVehicle(VehicleDto vehicleDto) {
		LOGGER.debug("begin");
		VehicleDAO vehicleDAO = new VehicleDAOImpl();
		return vehicleDAO.updateVehicle(vehicleDto);
	}

	/**
	 * Update user info.
	 * 
	 * @param customerDtoReq
	 * @return boolean
	 */
	public boolean updateUser(CustomerDto customerDtoReq) {
		LOGGER.debug("begin");
		CustomerDAO customerDAO = new CustomerDAOImpl();
		LOGGER.info("customerDtoReq: " + customerDtoReq);
		return customerDAO.updateCustomer(customerDtoReq);
	}

}
